import React, {useEffect, useState} from 'react';
import axios, {get} from "axios";
import {upGoodsList, useSelectorGoods} from "./store/slices/goods";
import {useDispatch} from "react-redux";

function App() {
    const {goodsList} = useSelectorGoods();
    const dispatch = useDispatch();
    const getGoodsList = async function () {
        const {data} = await axios.get("http://localhost:3000/goodsList");
        dispatch(upGoodsList(data))
    }
    useEffect(function () {
        getGoodsList();
    }, [])
    return (
        <div>
            {
                goodsList.map(item => (
                    <div key={item.id}>
                        <p>商品名称：{item.goodsName}</p>
                        <p>商品价格：{item.goodsPrice}</p>
                        <hr/>
                    </div>
                ))
            }
        </div>
    );
}

export default App;